package com.biboheart.adapter.express.support;

import com.biboheart.adapter.express.operation.Calculate;

import java.math.BigDecimal;
import java.math.RoundingMode;

final class DivisionCalculate implements Calculate<Double, Number, Number> {
    @Override
    public Double calc(Number left, Number right) {
        if (null == left || null == right || BigDecimal.ZERO.compareTo(new BigDecimal(String.valueOf(right))) == 0) {
            return BigDecimal.ZERO.doubleValue();
        }
        return new BigDecimal(String.valueOf(left)).divide(new BigDecimal(String.valueOf(right)), 4, RoundingMode.HALF_UP).doubleValue();
    }

    @Override
    public Double calc(Number num) {
        return null;
    }
}
